struct Cardinal;
struct BlueJay;
struct Turkey;

trait Red {}
trait Blue {}

impl Red for Cardinal {}
impl Blue for BlueJay {}

// 这些函数只对实现了相应的trait的类型有效
// 事实上这些trait内部是空的,但这没有关系
fn red<T: Red>(_: T) -> &'static str {"red"}
fn blue<T: Blue>(_: T) -> &'static str {"blue"}
// 这些函数只对实现了相应的trait的类型有效
fn main() {
    let cardinal = Cardinal;
    let blue_jay = BlueJay;
    let _turkey = Turkey;
    println!("cardinal is {}", red(cardinal));
//     由于约束`red()`不能作用于`blue_jay`（蓝松鸟）,反过来一样
    println!("blue jay is {}", blue(blue_jay));

    // println!("turkey is {}", red(_turkey));
//     ^ red不能作用于`_turkey`（火鸡）
}
